package huu.phong.sshchecker;

import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.Date;

public class SSHOutputStream {
	
	private PrintWriter writer;
	
	private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH-mm-ss");
	
	public SSHOutputStream(String filename) {
		try {
			writer = new PrintWriter(dateFormat.format(new Date()) + "_scanned_" + filename);
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
	}
	
	public SSHOutputStream() {
		try {
			writer = new PrintWriter(dateFormat.format(new Date()) + ".txt");
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
	}
	
	public synchronized void println(String content) {
		writer.println(content);
		writer.flush();
	}
	
	public synchronized void close() {
		writer.flush();
		writer.close();
	}
}
